#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int main()
{
    int n;
    while (scanf("%d", &n) != EOF)
    {
        int t = pow(3, n);
        printf("%d\n", t - 1);
    }
    return 0;
}